﻿using System;

namespace AVCUMPlatform.HelperLibrary.Cache
{
    /// <summary>
    /// 缓存方法接口
    /// </summary>
    public interface ICache
    {
        /// <summary>
        /// 移除
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        bool Remove(string key);
        /// <summary>
        /// 判断是否存在
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        bool IsExists(string key);
        /// <summary>
        /// 根据主键获取
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="key"></param>
        /// <returns></returns>
        T Get<T>(string key);
        /// <summary>
        /// 设置缓存
        /// </summary>
        /// <param name="key"></param>
        /// <param name="value"></param>
        /// <param name="expiry"></param>
        /// <param name="isSliding">是否滑动</param>
        /// <returns></returns>
        bool Set<T>(string key, T value, TimeSpan expiry, bool isSliding = false) where T:class;
    }
}
